﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using CoreShop.Model;
using CoreShop.Services;
using gregn6Lib;

namespace CoreShop.PrintService
{
    public partial class frmReportDesigner : Form
    {
        private corecmsprintbilltemplate billtemplate;
        private Axgrdes6Lib.AxGRDesigner axGRDesigner;
        private Axgregn6Lib.AxGRPrintViewer axGRPrintViewer1 = new Axgregn6Lib.AxGRPrintViewer();
        private GridppReport currentReport = new GridppReport();
        private GridppReport viewerReport = new GridppReport();
        protected GridppReport SubFoodType = new GridppReport();//商品分类
        protected GridppReport SubFoodDepart = new GridppReport();//商品部门
        protected GridppReport SubPayment = new GridppReport();//合计付款方式
        protected GridppReport SubPresent = new GridppReport();//合计付款方式
        private string currentReportFullPath = string.Empty;
        private Button btnSave;

        public frmReportDesigner()
        {
            InitializeComponent();
            this.axGRDesigner = new Axgrdes6Lib.AxGRDesigner();
            this.btnSave = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.axGRDesigner)).BeginInit();
            this.SuspendLayout();
            // 
            // axGRDesigner
            // 
            this.axGRDesigner.Dock = System.Windows.Forms.DockStyle.Fill;
            this.axGRDesigner.Enabled = true;
            this.axGRDesigner.Location = new System.Drawing.Point(0, 24);
            this.axGRDesigner.Name = "axGRDesigner";
            this.axGRDesigner.Size = new System.Drawing.Size(556, 394);
            this.axGRDesigner.TabIndex = 1;
            // 
            // btnSave
            // 
            //this.btnSave.Location = new System.Drawing.Point(25, 0);
            //this.btnSave.Name = "btnSave";
            //this.btnSave.Size = new System.Drawing.Size(75, 23);
            //this.btnSave.TabIndex = 1;
            //this.btnSave.Text = "保存(&S)";
            //this.btnSave.UseVisualStyleBackColor = true;
            //this.btnSave.Click += new System.EventHandler(this.btnSaveReport);
            //this.pnlDesign.Controls.Add(this.btnSave);

            this.btnSaveEx.Location = new System.Drawing.Point(25, 3);
            this.btnSaveEx.Size = new System.Drawing.Size(32, 22);
            this.pnlDesign.Controls.Add(this.btnSaveEx);
            this.pnlDesign.Controls.Add(this.axGRDesigner);
            
            ((System.ComponentModel.ISupportInitialize)(this.axGRDesigner)).EndInit();
            this.axGRPrintViewer1 = new Axgregn6Lib.AxGRPrintViewer();
            ((System.ComponentModel.ISupportInitialize)(this.axGRPrintViewer1)).BeginInit();
            this.axGRPrintViewer1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.axGRPrintViewer1.Enabled = true;
            this.axGRPrintViewer1.Location = new System.Drawing.Point(0, 0);
            this.axGRPrintViewer1.Name = "axGRPrintViewer1";
            this.axGRPrintViewer1.Size = new System.Drawing.Size(712, 470);
            this.axGRPrintViewer1.TabIndex = 1;            
            this.pnlPrintViewer.Controls.Add(this.axGRPrintViewer1);                      
            ((System.ComponentModel.ISupportInitialize)(this.axGRPrintViewer1)).EndInit();
            this.ResumeLayout(false);
            axGRDesigner.Report = currentReport;
            axGRDesigner.SaveReport -= btnSaveReport;
        }

        private void btnSaveReport(object sender, EventArgs e)
        {
            SaveReport();
        }

        public static void SaveReportAs(object sender, EventArgs e)
        {
           // MessageBox.Show("哈哈");
        }

        #region 报表渲染数据

        private void ReportFetchRecord()
        {
            try
            {
                viewerReport.DetailGrid.Recordset.Empty();
                for (int i = 0; i < 1; i++)
                {
                    viewerReport.DetailGrid.Recordset.Append();
                    foreach (IGRField fld in viewerReport.DetailGrid.Recordset.Fields)
                    {
                        fld.Value = fld.Tag;
                    }
                    viewerReport.DetailGrid.Recordset.Post();
                }
            }
            catch { }
        }
        private void ReportFetchRecord_SubFoodType()
        {
            //获取子报表的内部报表对象  
            try
            {
                SubFoodType.DetailGrid.Recordset.Empty();
                for (int i = 0; i < 2; i++)
                {
                    SubFoodType.DetailGrid.Recordset.Append();
                    foreach (IGRField fld in SubFoodType.DetailGrid.Recordset.Fields)
                    {
                        fld.Value = fld.Tag;
                    }
                    SubFoodType.DetailGrid.Recordset.Post();
                }
            }
            catch { }
        }

        private void ReportFetchRecord_SubFoodDepart()
        {
            //获取子报表的内部报表对象  
            try
            {
                SubFoodDepart.DetailGrid.Recordset.Empty();
                for (int i = 0; i < 2; i++)
                {
                    SubFoodDepart.DetailGrid.Recordset.Append();
                    foreach (IGRField fld in SubFoodDepart.DetailGrid.Recordset.Fields)
                    {
                        fld.Value = fld.Tag;
                    }
                    SubFoodDepart.DetailGrid.Recordset.Post();
                }
            }
            catch { }
        }

        //在C#中一次填入一条记录不能成功，只能使用一次将记录全部填充完的方式
        private void ReportFetchRecord_SubPresent()
        {
            //获取子报表的内部报表对象  
            try
            {
                SubPresent.DetailGrid.Recordset.Empty();
                for (int i = 0; i < 1; i++)
                {
                    SubPresent.DetailGrid.Recordset.Append();
                    foreach (IGRField fld in SubPresent.DetailGrid.Recordset.Fields)
                    {
                        fld.Value = fld.Tag;
                    }
                    SubPresent.DetailGrid.Recordset.Post();
                }
            }
            catch { }
        }

        //在C#中一次填入一条记录不能成功，只能使用一次将记录全部填充完的方式
        private void ReportFetchRecord_SubRptPay()
        {
            //获取子报表的内部报表对象  
            try
            {
                SubPayment.DetailGrid.Recordset.Empty();
                for (int i = 0; i < 1; i++)
                {
                    SubPayment.DetailGrid.Recordset.Append();
                    foreach (IGRField fld in SubPayment.DetailGrid.Recordset.Fields)
                    {
                        fld.Value = fld.Tag;
                    }
                    SubPayment.DetailGrid.Recordset.Post();
                }
            }
            catch { }
        }

        private void LoadReport(corecmsprintbilltemplate billtemplate)
        {
            try
            {
                if (string.IsNullOrEmpty(billtemplate.reportData)) return;
                axGRPrintViewer1.Stop();
                viewerReport.LoadFromStr(billtemplate.reportData);
                //viewerReport.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecord);
                //try
                //{
                //    SubFoodType = viewerReport.ControlByName("SubFoodType").AsSubReport.Report;
                //    SubFoodType.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecord_SubFoodType);
                //}
                //catch { }
                //try
                //{
                //    SubFoodDepart = viewerReport.ControlByName("SubFoodDepart").AsSubReport.Report;
                //    SubFoodDepart.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecord_SubFoodDepart);
                //}
                //catch { }
                //try
                //{
                //    SubFoodDepart = viewerReport.ControlByName("SubFoodDepart").AsSubReport.Report;
                //    SubFoodDepart.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecord_SubFoodDepart);
                //}
                //catch { }
                //try
                //{
                //    SubPresent = viewerReport.ControlByName("SubPresent").AsSubReport.Report;
                //    SubPresent.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecord_SubPresent);
                //}
                //catch { }

                //try
                //{
                //    SubPayment = viewerReport.ControlByName("SubPayment").AsSubReport.Report;
                //    SubPayment.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecord_SubRptPay);
                //}
                //catch { }
                axGRPrintViewer1.Report = viewerReport;
                axGRPrintViewer1.Start();
            }
            catch { }
        }

        #endregion

        public void AttachReport(GridppReport Report, corecmsprintbilltemplate _billtemplate)
        {
            //设定查询显示器关联的报表
            billtemplate = _billtemplate;
            axGRDesigner.Report = Report;
            currentReport = Report;
            viewerReport = Report;
            LoadReport(billtemplate);
            //axGRDesigner1.Dirty = true;
        }

        /// <summary>
        ///  打开报表菜单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void openMenuItem_Click(object sender, EventArgs e)
        {
            OpenReport();
        }
        /// <summary>
        /// 打开报表
        /// </summary>
        private void OpenReport()
        { 
            OpenFileDialog of = new OpenFileDialog();
            of.Filter = "报表模板(*.grf)|*.grf|所有文件(*.*)|*.*";
            of.FilterIndex = 0;
            of.RestoreDirectory = true;
            if (of.ShowDialog() != DialogResult.OK)
                return;

            //currentReport.Clear();
            //axGRDesigner.Reload();
            currentReportFullPath = of.FileName;
            currentReport.LoadFromFile(currentReportFullPath);
            if (currentReport.DetailGrid != null)
                currentReport.DetailGrid.Recordset.ConnectionString = "currentReport.DetailGrid.Recordset.ConnectionString";
            axGRDesigner.Reload();
            this.Text = currentReportFullPath;
        }
        /// <summary>
        /// 保存报表菜单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void saveMenuItem_Click(object sender, EventArgs e)
        {
            SaveReport();
        }
        /// <summary>
        /// 保存报表
        /// </summary>
        private void SaveReport()
        {
            axGRPrintViewer1.Stop();
            axGRDesigner.Post();
            billtemplate.reportData = currentReport.SaveToStr();
            var bl = new corecmsprintbilltemplateServices().UpdateAsync(billtemplate);
            if (!bl)
            {
                MessageBox.Show("保存失败。","提示:");
                return;
            }
            LoadReport(billtemplate);
        }
        /// <summary>
        /// 报表另存为
        /// </summary>
        private void AsSaveReport()
        {
            SaveFileDialog saveFileDlg = new SaveFileDialog();
            saveFileDlg.Filter = "报表文件(*.grf)|*.grf";
            saveFileDlg.CheckFileExists = false;
            saveFileDlg.DefaultExt = "grf";
            if (saveFileDlg.ShowDialog() != DialogResult.OK)
                return;
            currentReportFullPath = saveFileDlg.FileName;
            if (File.Exists(currentReportFullPath))
                File.Delete(currentReportFullPath);
            axGRDesigner.Post();
            currentReport.SaveToFile(currentReportFullPath);
            //ReOpenReport();
        }
        /// <summary>
        ///  重新打开报表
        /// </summary>
        private void ReOpenReport()
        {
            currentReport.Clear();
            currentReport.LoadFromFile(currentReportFullPath);
            axGRDesigner.Report = currentReport;
            axGRDesigner.Reload();
            this.Text = currentReportFullPath;
        }
        /// <summary>
        ///  新建按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void newMenuItem_Click(object sender, EventArgs e)
        {
            NewReport();
        }
        /// <summary>
        /// 新建报表
        /// </summary>
        private void NewReport()
        {

            this.Text = "报表设计器";
            currentReportFullPath = string.Empty;

            currentReport.Clear();
            //IGRDetailGrid DetailGrid = currentReport.InsertDetailGrid();
            //DetailGrid.Recordset.ConnectionString = "abc";
            axGRDesigner.Reload();
        }

        private void axGRDesigner_SaveReport(object sender, EventArgs e)
        {   
            axGRDesigner.DefaultAction = false;
            SaveReport();
        }

        private void anotherSaveMenuItem_Click(object sender, EventArgs e)
        {
            //if (currentReportFullPath == string.Empty)
            //    return;
            AsSaveReport();
        }

        private void exitMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        /// <summary>
        ///  撤消菜单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cancelMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaEditUndo);
        }
        /// <summary>
        ///  重复操作菜单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void repeatMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaEditRedo);
        }
        /// <summary>
        ///  剪切
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cutMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaEditCut);
        }
        /// <summary>
        /// 复制
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void copyMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaEditCopy);
        }
        /// <summary>
        /// 粘贴
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void plasterMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaEditPaste);
        }
        /// <summary>
        ///  删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void deleteMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaEditDelete);
        }
        /// <summary>
        /// 全选
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void selectAllMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaEditSelectAll);
        }
        /// <summary>
        /// 自动调整大小
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void autoResizetMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaAutoSizeControl);
        }
        /// <summary>
        ///  根据查询自动生成字段
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buildFieldMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaAutoGenField);  
        }
        /// <summary>
        /// 根据字段生成列
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buildColumnMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaAutoGenColumn);
        }

        private void axGRDesigner_OpenReport(object sender, EventArgs e)
        {

        }
        /// <summary>
        /// 工具栏
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolbarMenuItem_Click(object sender, EventArgs e)
        {
            //axGRDesigner.Post();
            //currentReport.DetailGrid.Recordset.QuerySQL = "Select * from pub_Corp where corpid = 8000";
            //currentReport.DetailGrid.Recordset.ConnectionString = "adfadsf";
            //axGRDesigner.Reload();
            if (this.toolbarMenuItem.Checked)
            {
                axGRDesigner.ShowToolbar = false;
                axGRDesigner.Refresh();
                this.toolbarMenuItem.Checked = false;
            }
            else
            {
                axGRDesigner.ShowToolbar = true;
                axGRDesigner.Refresh();
                this.toolbarMenuItem.Checked = true;
            }
        }
        /// <summary>
        ///  对象浏览窗口
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void objectLookMenuItem_Click(object sender, EventArgs e)
        {
            if (this.objectLookMenuItem.Checked)
            {
                axGRDesigner.ShowExplorer = false;
                axGRDesigner.Refresh();
                this.objectLookMenuItem.Checked = false;
            }
            else
            {
                axGRDesigner.ShowExplorer = true;
                axGRDesigner.Refresh();
                this.objectLookMenuItem.Checked = true;
            }
        }
        /// <summary>
        /// 属性浏览窗口
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void propertyEditMenuItem_Click(object sender, EventArgs e)
        {
            if (this.propertyEditMenuItem.Checked)
            {
                axGRDesigner.ShowInspector = false;
                axGRDesigner.Refresh();
                this.propertyEditMenuItem.Checked = false;
            }
            else
            {
                axGRDesigner.ShowInspector = true;
                axGRDesigner.Refresh();
                this.propertyEditMenuItem.Checked = true;
            }
        }
        /// <summary>
        /// 布局窗口位于左边
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void layoutWindowLeftMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.WindowLayout = grdes6Lib.GRDesignerWindowLayout.grdwlLayoutAtLeft;
        }
        /// <summary>
        /// 布居局窗口位于右边
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void layoutWindowRightMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.WindowLayout = grdes6Lib.GRDesignerWindowLayout.grdwlLayoutAtRight;
        }
        /// <summary>
        ///  普通视图
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void commonViewMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.ViewMode = grdes6Lib.GRDesignerViewMode.grvmInNormalDesign;
        }
        /// <summary>
        /// 页面视图
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pageViewMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.ViewMode = grdes6Lib.GRDesignerViewMode.grvmInPageDesign;
        }
        private void toolStripPageViewMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.ViewMode = grdes6Lib.GRDesignerViewMode.grvmInPrint;
        }
        private void toolStripDisplayViewMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.ViewMode = grdes6Lib.GRDesignerViewMode.grvmInDisplay;
        }
        /// <summary>
        /// 中文页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void chineseInterfaceMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.AsNativeUI = true;
        }
        /// <summary>
        ///  英文页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void englishInterfaceMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.AsNativeUI = false;
        }
        /// <summary>
        /// 页面设置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pageSetMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaReportPaperSetting);
        }
        /// <summary>
        /// 数据库查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void databaseQueryMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaSetupDBQuery);
        }
        /// <summary>
        /// 列标题布局
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void columnTitleLayoutMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaReportColumnTitleLayout);
        }
        /// <summary>
        /// 字段集合
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void fieldCollectionMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaReportFieldCollection);
        }
        /// <summary>
        /// 组集合
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void groupCollectionMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaReportGroupCollection);
        }
        /// <summary>
        /// 列集合
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void columnCollectionMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaReportColumnCollection);
        }
        /// <summary>
        /// 参数集合
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void parameterCollectionMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaReportParameterCollection);
        }
        /// <summary>
        /// 静态文本框
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StaticBoxMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.PrepareInsertControl(1);
        }
        /// <summary>
        /// 综合文件框
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void memoBoxMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.PrepareInsertControl(8);
        }
        /// <summary>
        ///  字段框
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void fieldBoxMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.PrepareInsertControl(4);
        }
        /// <summary>
        /// 统计框
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void summaryBoxMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.PrepareInsertControl(5);
        }
        /// <summary>
        /// 系统变量框
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void systemBoxMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.PrepareInsertControl(3);
        }
        /// <summary>
        /// RTF框
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void richtextBoxMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.PrepareInsertControl(6);
        }
        /// <summary>
        /// 图形框
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void shapeBoxMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.PrepareInsertControl(2);
        }
        /// <summary>
        /// 线段框
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lineMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.PrepareInsertControl(10);
        }
        /// <summary>
        /// 图片框
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pictureBoxMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.PrepareInsertControl(7);
        }
        /// <summary>
        ///  子报表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bsubReportMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.PrepareInsertControl(9);
        }
        /// <summary>
        ///  页眉
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pageHeaderMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaInsertPageHeader);
        }
        /// <summary>
        /// 页脚
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pageFooterMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaInsertPageFooter);
        }
        /// <summary>
        /// 报表头
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void reportHeaderMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaInsertReportHeader);
        }
        /// <summary>
        /// 报表尾
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void reportFooterMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaInsertReportFooter);
        }
        /// <summary>
        /// 明细网格
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void detailGridMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaInsertDetailGrid);
        }
        /// <summary>
        /// 分组
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gourpMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaInsertGroup);
        }
        /// <summary>
        /// 列
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void columnMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaInsertColumn);
        }
        /// <summary>
        /// 字段
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FieldMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaInsertField);
        }
        /// <summary>
        /// 参数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void parameterMenuItem1_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaInsertParameter);
        }
        /// <summary>
        /// 左对齐
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void alignLeftMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatAlignLeft);
        }
        /// <summary>
        /// 居中对齐
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void alignCenterMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatAlignCenter);
        }
        /// <summary>
        /// 右对齐
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void alignRightMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatAlignRight);
        }
        /// <summary>
        /// 顶端对齐
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void alignTopMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatAlignTop);
        }
        /// <summary>
        /// 中间对齐
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void alignMiddleMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatAlignMiddle);
        }
        /// <summary>
        /// 底部对齐
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void alignBottomMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatAlignBottom);
        }
        /// <summary>
        /// 对齐到栅格
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void alignGridMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatAlignToGrid);
        }
        /// <summary>
        /// 使宽度相同
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void sameWidthMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatSizeSameWidth);
        }
        /// <summary>
        /// 使高度相同
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void sameHightMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatSizeSameHeight);
        }
        /// <summary>
        /// 两者相同
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void sameBothMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatSizeSameBoth);
        }
        /// <summary>
        ///  按网络调整大小
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void sameGridMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatSizeToGrid);
        }
        /// <summary>
        ///  相同间隔
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lSpaceEquallyMenu_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatSpaceEquallyHorizontal);
        }
        /// <summary>
        /// 递增
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lSpaceIncraseMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatSpaceIncreaseHorizontal);
        }
        /// <summary>
        /// 递减
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lSpaceDecreaseMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatSpaceDecreaseHorizontal);
        }
        /// <summary>
        /// 移除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lSpaceRemoveMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatSpaceRemoveHorizontal);
        }
        /// <summary>
        ///  垂直相同间隔
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void vSpaceEquallyMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatSpaceEquallyVertical);
        }
        /// <summary>
        ///  垂直递增
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void vSpaceIncreaseMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatSpaceIncreaseVertical);
        }
        /// <summary>
        /// 垂直递减
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void vSpaceDecreaseMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatSpaceDecreaseVertical);
        }
        /// <summary>
        ///  垂直移除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void vSpaceRemoveMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatSpaceRemoveVertical);
        }
        /// <summary>
        /// 置于顶层
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bringToFrontMenu_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatOrderBringToFront);
        }
        /// <summary>
        /// 置于底层
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void sendToBackMenuItem_Click(object sender, EventArgs e)
        {
            axGRDesigner.DoAction(grdes6Lib.GRDesignerAction.grdaFormatOrderSendToBack);
        }

        private void axGRDesigner_LayoutPanelContextMenu(object sender, EventArgs e)
        {

        }

        private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {

        }
    }
}